package com.lkd.controller;

import com.lkd.dto.VmTypeDTO;
import com.lkd.entity.VmType;
import com.lkd.result.TableInfo;
import com.lkd.service.VmTypeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: Z.lx
 * @Date: 2025/8/17 16:11
 * @Description:
 **/
@RestController
@RequestMapping("/api/vm-service/vmType")
@Slf4j
public class VmTypeController {

    @Autowired
    private VmTypeService vmTypeService;

    /**
    * @Description 售货机类型
    * @Param [vmType]
    * @Date 2025/8/17 16:19
    **/
    @GetMapping("/search")
    public TableInfo<VmType> list(VmTypeDTO vmTypeDTO){
        log.info("查询售货机类型{}",vmTypeDTO);
        return vmTypeService.list(vmTypeDTO);
    }
    /**
    * @Description 新增售货机类型
    * @Param [vmType]
    * @Date 2025/8/17 16:19
    **/
    @PostMapping
    public boolean add(@RequestBody VmTypeDTO vmTypeDTO){
        log.info("新增售货机类型{}",vmTypeDTO);
        return vmTypeService.add(vmTypeDTO);
    }
    /**
    * @Description 修改售货机类型
    * @Param [vmType]
    * @Date 2025/8/17 16:19
    **/
    @PutMapping("/{typeId}")
    public boolean update(@PathVariable Integer typeId,@RequestBody VmTypeDTO vmTypeDTO){
        log.info("修改售货机类型{}",vmTypeDTO);
        vmTypeDTO.setTypeId(typeId);
        return vmTypeService.update(vmTypeDTO);
    }
    /**
    * @Description 删除售货机类型
    * @Param [vmTypeId]
    * @Date 2025/8/17 16:19
    **/
    @DeleteMapping("/{vmTypeId}")
    public boolean delete(@PathVariable String vmTypeId){
        log.info("删除售货机类型{}",vmTypeId);
        return vmTypeService.delete(vmTypeId);
    }

    /**
    * @Description 根据ID查询售货机类型
    * @Param [vmTypeId]
    * @Date 2025/8/17 16:19
    **/
    @GetMapping("/{vmTypeId}")
    public VmType getById(@PathVariable String vmTypeId){
        log.info("查询售货机类型{}",vmTypeId);
        return vmTypeService.getById(vmTypeId);
    }
}
